﻿using System;
using Framework.Dependency;
using Framework.Validators.User;
using Interfaces.Validation.Services;
using Microsoft.Practices.EnterpriseLibrary.Validation;
using Microsoft.Practices.EnterpriseLibrary.Validation.Validators;
using Microsoft.Practices.Unity;

namespace BusinessLogic.Models.ValidationAttributes
{
    [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
    public class UserNameNotExistValidationAttribute : ValidatorAttribute
    {
        public string Message { get; set; }

        protected override Validator DoCreateValidator(Type targetType)
        {
            return new UserNameNotExistValidator(Message, Tag,
                                              DependencyManager.Container.Resolve<IUserValidationService>());
        }
    }
}
